<extend name="Layout/ins_page"/>
<block name="content">
	<input type="hidden" name="popup_val" id="popup_val">
	<input type="hidden" name="popup_name" id="popup_name">
	{:W('PageHeader/simple',array('name'=>$folder_name))}
	<div class="oprator-panel" id="uploader">
		<a class="btn" onclick="go_return_url()">返回</a>
		<a id="btn_import" class="btn">导入</a>
		<a id="btn_export" class="btn">导出</a>
		<div class="split"></div>
		<a id="btn_add" class="btn">新增</a>
		<a id="btn_save" class="btn">保存</a>
		<span class="l">|</span>
		<a id="btn_del" class="btn btn-del">删除</a>
	</div>
	<div class="sub-frame">
		<div class="sub-sidebar gray">
			<div class="well" style="max-height: 432px;overflow-y:auto;">
				<php>
					echo $menu
				</php>
			</div>
		</div>
		<div class="sub-content gray">
			<form method='post' id="form_data" >
				<input type="hidden" name="controller" id="controller" value="{$Think.CONTROLLER_NAME}">
				<input type="hidden" name="row_type" id="row_type" value="{$row_type}">
				<input type="hidden" name="id" id="id" >
				<input type="hidden" id="opmode" name="opmode" value="edit">
				<input type="hidden" name="ajax" id="ajax" value="1">

				<div class="layui-sub-form-item">
					<label class="layui-form-label" for="name">名称*：</label>
					<div class="layui-input-block">
						<input class="layui-input" type="text" id="name" name="name" check="required" info="请输入名称">
					</div>
				</div>
				<div class="layui-sub-form-item">
					<label class="layui-form-label" for="layout">控件布局：</label>
					<div class="layui-input-block x-select col-12">
						<select name="layout" id="layout" check="required" info="请选择控件布局" class="layui-input">
							<option value="">请选择 </option>
							<option value="1">一行两列</option>
							<option value="2">一行一列</option>
							<option value="3">占一整行</option>
							<option value="4">由控件控制</option>
						</select>
					</div>
				</div>
				<div class="layui-sub-form-item">
					<label class="layui-form-label" for="type">控件类型*：</label>
					<div class="layui-input-block x-select col-12">
						<select name="type" id="type" check="required" info="请选择控件类型" class="layui-input">
							<option value="">请选择</option>
							<option value="popup">弹窗选择</option>
							<option value="add_file">文件上传</option>
							<option value="text">单行文本</option>
							<option value="date">日期 </option>
							<option value="datetime">日期+时间 </option>
							<option value="select">列表</option>
							<option value="link_select">联动列表</option>
							<option value="radio">单选</option>
							<option value="checkbox">多选 </option>
							<option value="textarea">多行文本 </option>
							<option value="editor">编辑器</option>
							<option value="simple">简易编辑器</option>
							<option value="help">帮助 </option>
							<option value="hr">分隔符</option>
							<option value="title">标题</option>
							<option value="user_name">当前用户</option>
							<option value="dept_name">当前部门</option>
						</select>
					</div>
				</div>
				<div class="layui-sub-form-item">
					<label class="layui-form-label" for="data">控件数据：</label>
					<div class="layui-input-block">
						<input  class="layui-input" type="text" id="data" name="data" >
					</div>
				</div>
				<div class="layui-sub-form-item">
					<label class="layui-form-label" for="config">设置：</label>
					<div class="layui-input-block">
						<input  class="layui-input" type="text" id="config" name="config" >
					</div>
				</div>
				<div class="layui-sub-form-item =">
					<label class="layui-form-label" for="sort">排序：</label>
					<div class="layui-input-block">
						<input class="layui-input" type="text" id="sort" name="sort" >
					</div>
				</div>
				<div class="layui-sub-form-item">
					<label class="layui-form-label" for="validate">验证：</label>
					<div class="layui-input-block col-12 x-select">
						<select name="validate" id="validate" class="layui-input col-12">
							<option value="">请选择 <option value="required">必选 <option value="email">邮件 <option value="number">数字
						</select>
					</div>
				</div>
				<div class="layui-sub-form-item">
					<label class="layui-form-label" for="msg">错误提示：</label>
					<div class="layui-input-block">
						<input  class="layui-input" type="text" id="msg" name="msg" >
					</div>
				</div>
			</form>
		</div>
	</div>
	{:W('PageHeader/sub',array('name'=>"自定义字段显示预览"))}
	<div class="sub-frame gray">
		<form method='post'  class="frame">
			<volist name="field_list" id="udf_vo">
				{:W('UserDefineField/edit',array($udf_vo))}
			</volist>
		</form>
	</div>
</block>
<block name="js">
	<script>
		layui.use(['global', 'uploader', 'udf_field'], function() {
			var $ = layui.jquery;
			set_return_url();

			$(".sub-sidebar .tree_menu  a").click(function() {
				$(".sub-sidebar .tree_menu  a").removeClass("active");
				$(this).addClass("active");
				send_ajax("{:U('UdfField/read')}", "id=" + $(this).attr("node"), function(data) {
					showdata(data);
				});
				return false;
			});

			function showdata(result) {
				for (var s in result.data) {
					set_val(s, result.data[s]);
				}
			};

			$('#btn_import').on('click', function() {
				window.open("{:U('UdfField/import',array('row_type'=>$row_type,'controller'=>$controller))}", '_self');
			});

			$('#btn_save').on('click', function() {
				send_form('form_data', "__SELF__", '__SELF__', function(ret) {
					if (ret.status) {
						layer.msg(ret.info);
						location.reload(true);
					} else {
						layer.msg(ret.info);
						return false;
					}
				});
			});

			$('#btn_export').on('click', function() {
				window.open("{:U('UdfField/export',array('row_type'=>$row_type,'controller'=>$controller))}", "_blank");
				return false;
			});

			$('#btn_del').on('click', function() {
				if ($(".sub-sidebar a.active").length == 0) {
					layer.msg('请选择要删除的数据');
					return false;
				}
				//信息框-例2
				layer.msg('确定要删除吗?', {
					time : 0,
					btn : ['确定', '取消'],
					yes : function(index) {
						$("#opmode").val("del");
						send_form("form_data", "__SELF__", "__SELF__", function(ret) {
							if (ret.status == 1) {
								parent.layer.msg(ret.info);
								parent.layer.close(index);
								parent.location.reload(true);
							} else {
								parent.layer.msg(ret.info);
								return false;
							}
						});
					},
					no : function(index) {
						layer.close(index);
					}
				});
			});

			$("#btn_add").on('click', function() {
				winopen("{:U('UdfField/add',array('controller'=>$controller,'row_type'=>$row_type))}", 560, 470);
			});

		});
	</script>
</block>